package com.dagene.weixin.repository;

import java.util.List;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.dagene.weixin.entity.AccessState;

public interface AccessStateDao extends CrudRepository<AccessState, Long> {

	List<AccessState> findByOpercode(int opercode, Sort sort);

	List<AccessState> findByOpercodeAndWorker(int opercode, String worker);

	AccessState findByOpercodeAndOpenid(int opercode, String openid);

	List<AccessState> findAllByOpercodeAndOpenid(int opercode, String openid);

	AccessState findByOpenidAndWorker(String openid, String worker);

	AccessState findByWorker(String worker);

	//@Query("select as from AccessState as where openid = ?1 or worker = ?1")
	@Query("select s from AccessState s where openid=?1 or worker>=?1")
	AccessState findByOpenidOrWorker(String openid);

	AccessState findByOpercodeAndMatchnumber(int opercode, int matchnumber);

}
